import 'dart:io';

import '../../helper/channelHelper.dart';
import 'package:url_launcher/url_launcher.dart';


  class GoToMap {

  static Future<bool>  gotoAMap(longitude, latitude) async {
    var url = '${Platform.isAndroid ? 'android' : 'ios'}amap://navi?sourceApplication=amap&lat=$latitude&lon=$longitude&dev=0&style=2';
 
    bool canLaunchUrl = await canLaunch(url);
    if(canLaunchUrl){
       return launch(url);
    }else{
      ChannelHelper.showToast("未检测到高德地图");
      return false;
    }
  }
 
  /// 腾讯地图
 
  /// 百度地图
  static Future<bool> gotoBaiduMap(longitude, latitude) async {
    var url = 'baidumap://map/direction?destination=$latitude,$longitude&coord_type=gcj02&mode=driving';
   // print(url);
   bool canLaunchUrl = await canLaunch(url);

    if(canLaunchUrl){
       return launch(url);
    }else{
      ChannelHelper.showToast("未检测到百度地图");
      return false;
    }
  
  }


  static void gotoTheMap(longitude, latitude) async {
    var bd1=await gotoBaiduMap(longitude, latitude);
    if(bd1)
    return;
    gotoAMap(longitude, latitude);
  }
 
}